﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//////////////////////////////////////
//  Gestion du texte de la console  //
//////////////////////////////////////

namespace Strom.Server.IO
{
    class ServerConsole
    {
        // Affiche un message puis revient à la ligne
        public static void WriteLine(string message, ConsoleColor color)
        {
            Console.ForegroundColor = color;
            Console.WriteLine(message);
            Console.ForegroundColor = ConsoleColor.Gray;
        }

        // Affiche un message
        public static void Write(string message, ConsoleColor color)
        {
            Console.ForegroundColor = color;
            Console.Write(message);
            Console.ForegroundColor = ConsoleColor.Gray;
        }

        // Affiche un message special
        public static void WriteSpecialMessage(string message, MessageType messageType)
        {
            if (Loader.LoadComplete)
                message = "\n" + message;

            WriteSpecialMessageCommand(message, messageType);

            if(Loader.LoadComplete)
                Console.Write("<{0}:{1}> ", ServerDatas.IP, ServerDatas.Port);
        }

        public static void WriteSpecialMessageCommand(string message, MessageType messageType)
        {
            switch (messageType)
            {
                case MessageType.Normal:
                    Console.WriteLine(message);
                    break;
                case MessageType.Success:
                    WriteLine(message, ConsoleColor.Green);
                    break;
                case MessageType.Fail:
                    WriteLine(message, ConsoleColor.Red);
                    break;
                case MessageType.Warning:
                    WriteLine(message, ConsoleColor.Yellow);
                    break;
                case MessageType.Event:
                    WriteLine(message, ConsoleColor.Cyan);
                    break;
            }
        }

        public enum MessageType
        {
            Normal,
            Success,
            Fail,
            Warning,
            Event
        }
    }
}
